home *** CD-ROM | disk | FTP | other *** search
/ Kit PC World De Ampliacion De Windows 95 / Kit PC World de ampliacion de Windows 95.iso / clarion / cw15 / tpw15.z / RELTREE.TPW < prev    next >
Text File  |  1995-09-07  |  38KB  |  992 lines

  1. #CONTROL(RelationTree,'Relation Tree Viewing List Box'),PRIMARY('Relation Tree Viewing List Box',OPTKEY),DESCRIPTION('View Relations of ' & %Primary),MULTI,WINDOW,HLP('~TPLControlRelationTree')
  2.   CONTROLS
  3.     LIST,AT(,,150,100),USE(?RelTree),FORMAT('800Lt@s200@'),FROM(Queue:RelTree)
  4.   END
  5. #LOCALDATA
  6. DisplayString        STRING(255)
  7. #ENDLOCALDATA
  8. #BUTTON('&Relation Tree Behavior'),AT(10,,180)
  9.   #SHEET
  10.     #TAB('&File Details'),HLP('~TPLControlRelationTree_FileDetails')
  11.       #PREPARE
  12.         #FIND(%ControlInstance,%ActiveTemplateInstance,%Control)
  13.       #ENDPREPARE
  14.       #BOXED('Tree Heading')
  15.         #PROMPT('Tree Heading &Text:',@S255),%TreeTitle
  16.         #ENABLE(%ControlHasIcon)
  17.           #PROMPT('Tree Heading &Icon:',@S255),%TreeTitleIcon
  18.         #ENDENABLE
  19.       #ENDBOXED
  20.       #BOXED('Primary File')
  21.         #PROMPT('&Display String:',@S255),%PrimaryDisplay
  22.         #PROMPT('&Update Procedure:',PROCEDURE),%PrimaryUpdate
  23.       #ENDBOXED
  24.       #BOXED('Secondary Files')
  25.         #BUTTON('&Secondary Files'),FROM(%Secondary,%Secondary & ' - ' & %SecondaryDisplay),INLINE,WHERE(%SecondaryType = 'MANY:1'),AT(,,,75)
  26.           #SHEET
  27.             #TAB('Secondary &File Details'),HLP('~TPLControlRelationTree_SecondaryFileDetails')
  28.               #PROMPT('&Display String:',@S255),%SecondaryDisplay
  29.               #PROMPT('&Update Procedure:',PROCEDURE),%SecondaryUpdate
  30.             #ENDTAB
  31.             #TAB('&Icons'),WHERE(%ControlHasIcon),HLP('~TPLControlRelationTree_Icons')
  32.               #PREPARE
  33.                 #FIND(%ControlInstance,%ActiveTemplateInstance,%Control)
  34.               #ENDPREPARE
  35.               #BOXED('Default Icon')
  36.                 #PROMPT('&Default Icon:',@S40),%SecondaryDefaultIcon
  37.               #ENDBOXED
  38.               #BOXED('Conditional Icon Usage')
  39.                 #BUTTON('&Conditional Icon Usage'),MULTI(%SecondaryConditionalIcons,%SecondaryIconCondition),INLINE,HLP('~TPLControlRelationTree_ConditionalIconUsage')
  40.                   #PROMPT('&Condition:',@S255),%SecondaryIconCondition
  41.                   #PROMPT('&Icon:',@S40),%SecondaryConditionalIcon
  42.                 #ENDBUTTON
  43.               #ENDBOXED
  44.             #ENDTAB
  45.             #TAB('&Colors'),WHERE(%ControlhasColor),HLP('~TPLControlRelationTree_Colors')
  46.               #PREPARE
  47.                 #FIND(%ControlInstance,%ActiveTemplateInstance,%Control)
  48.               #ENDPREPARE
  49.               #BOXED('Default Colors')
  50.                 #PROMPT('Foreground &Normal:',COLOR),%DefaultSecondaryForegroundNormal,DEFAULT(-1)
  51.                 #PROMPT('&Background Normal:',COLOR),%DefaultSecondaryBackgroundNormal,DEFAULT(-1)
  52.                 #PROMPT('&Foreground Selected:',COLOR),%DefaultSecondaryForegroundSelected,DEFAULT(-1)
  53.                 #PROMPT('Background &Selected:',COLOR),%DefaultSecondaryBackgroundSelected,DEFAULT(-1)
  54.               #ENDBOXED
  55.               #BOXED('Conditional Color Assignments')
  56.                 #BUTTON('Conditional Color Assignments'),MULTI(%SecondaryConditionalColors,%SecondaryColorCondition),INLINE,HLP('~TPLControlRelationTree_ConditionalColorAssignments')
  57.                   #PROMPT('&Condition:',@S255),%SecondaryColorCondition
  58.                   #PROMPT('Foreground &Normal:',COLOR),%ConditionalSecondaryForegroundNormal,DEFAULT(-1)
  59.                   #PROMPT('&Background Normal:',COLOR),%ConditionalSecondaryBackgroundNormal,DEFAULT(-1)
  60.                   #PROMPT('&Foreground Selected:',COLOR),%ConditionalSecondaryForegroundSelected,DEFAULT(-1)
  61.                   #PROMPT('Background &Selected:',COLOR),%ConditionalSecondaryBackgroundSelected,DEFAULT(-1)
  62.                 #ENDBUTTON
  63.               #ENDBOXED
  64.             #ENDTAB
  65.           #ENDSHEET
  66.         #ENDBUTTON
  67.       #ENDBOXED
  68.     #ENDTAB
  69.     #TAB('&Icons'),WHERE(%ControlHasIcon),HLP('~TPLControlRelationTree_Icons')
  70.       #PREPARE
  71.         #FIND(%ControlInstance,%ActiveTemplateInstance,%Control)
  72.       #ENDPREPARE
  73.       #BOXED('Default Icon')
  74.         #PROMPT('&Default Icon:',@S40),%PrimaryDefaultIcon
  75.       #ENDBOXED
  76.       #BOXED('Conditional Icon Usage')
  77.         #BUTTON('&Conditional Icon Usage'),MULTI(%PrimaryConditionalIcons,%PrimaryIconCondition),INLINE,HLP('~TPLControlRelationTree_ConditionalIconUsage')
  78.           #PROMPT('&Condition:',@S255),%PrimaryIconCondition
  79.           #PROMPT('&Icon:',@S40),%PrimaryConditionalIcon
  80.         #ENDBUTTON
  81.       #ENDBOXED
  82.     #ENDTAB
  83.     #TAB('&Colors'),WHERE(%ControlHasColor),HLP('~TPLControlRelationTree_Colors')
  84.       #PREPARE
  85.         #FIND(%ControlInstance,%ActiveTemplateInstance,%Control)
  86.       #ENDPREPARE
  87.       #BOXED('Default Colors')
  88.         #PROMPT('Foreground &Normal:',COLOR),%DefaultPrimaryForegroundNormal,DEFAULT(-1)
  89.         #PROMPT('&Background Normal:',COLOR),%DefaultPrimaryBackgroundNormal,DEFAULT(-1)
  90.         #PROMPT('&Foreground Selected:',COLOR),%DefaultPrimaryForegroundSelected,DEFAULT(-1)
  91.         #PROMPT('Background &Selected:',COLOR),%DefaultPrimaryBackgroundSelected,DEFAULT(-1)
  92.       #ENDBOXED
  93.       #BOXED('Conditional Color Assignments')
  94.         #BUTTON('Conditional Color Assignments'),MULTI(%PrimaryConditionalColors,%PrimaryColorCondition),INLINE,AT(,,,90),HLP('~TPLControlRelationTree_ConditionalColorAssignments')
  95.           #PROMPT('&Condition:',@S255),%PrimaryColorCondition
  96.           #PROMPT('Foreground &Normal:',COLOR),%ConditionalPrimaryForegroundNormal,DEFAULT(-1)
  97.           #PROMPT('&Background Normal:',COLOR),%ConditionalPrimaryBackgroundNormal,DEFAULT(-1)
  98.           #PROMPT('&Foreground Selected:',COLOR),%ConditionalPrimaryForegroundSelected,DEFAULT(-1)
  99.           #PROMPT('Background &Selected:',COLOR),%ConditionalPrimaryBackgroundSelected,DEFAULT(-1)
  100.         #ENDBUTTON
  101.       #ENDBOXED
  102.     #ENDTAB
  103.   #ENDSHEET
  104. #ENDBUTTON
  105. #CLASS('Format Tree','Format a variable in the ' & %ActiveTemplateInstanceDescription)
  106. #AT(%CustomGlobalDeclarations)
  107.   #INSERT(%FileControlSetFlags)
  108. #ENDAT
  109. #ATSTART
  110. #MESSAGE('Initializing Relation Tree',3)
  111. #INSERT(%FileControlInitialize)
  112. #DECLARE(%InstancePrefix)
  113. #DECLARE(%TreeQueue)
  114. #DECLARE(%TreeControl)
  115. #DECLARE(%TempLevel)
  116. #DECLARE(%TempParent)
  117. #DECLARE(%TempParentKey)
  118. #DECLARE(%InsertPopupText)
  119. #DECLARE(%ChangePopupText)
  120. #DECLARE(%DeletePopupText)
  121. #DECLARE(%TreeLevelFile),MULTI
  122. #DECLARE(%TreeLevel,%TreeLevelFile)
  123. #DECLARE(%TreeChildFile,%TreeLevelFile)
  124. #DECLARE(%TreeParentFile,%TreeLevelFile)
  125. #DECLARE(%TreeParentKey,%TreeLevelFile)
  126. #DECLARE(%TreeDisplay,%TreeLevelFile)
  127. #DECLARE(%UpdatesPresent)
  128. #DECLARE(%IconList),UNIQUE
  129. #DECLARE(%IconListType,%IconList)
  130. #FOR(%Control),WHERE(%ControlInstance = %ActiveTemplateInstance)
  131.   #SET(%TreeControl,%Control)
  132.   #SET(%TreeQueue,EXTRACT(%ControlStatement,'FROM',1))
  133. #ENDFOR
  134. #SET(%InsertPopupText,'&Insert')
  135. #SET(%ChangePopupText,'&Change')
  136. #SET(%DeletePopupText,'&Delete')
  137. #FIX(%Control,%TreeControl)
  138. #FIX(%File,%Primary)
  139. #ADD(%TreeLevelFile,%Primary)
  140. #SET(%TreeLevel,1)
  141. #SET(%TreeDisplay,%PrimaryDisplay)
  142. #SET(%UpdatesPresent,%False)
  143. #IF(%PrimaryUpdate)
  144.   #SET(%UpdatesPresent,%True)
  145. #ENDIF
  146. #IF(%ControlHasIcon)
  147.   #IF(%TreeTitleIcon)
  148.     #INSERT(%AddBrowseIcon,%TreeTitleIcon)
  149.   #ENDIF
  150.   #IF(%PrimaryDefaultIcon)
  151.     #INSERT(%AddBrowseIcon,%PrimaryDefaultIcon)
  152.   #ENDIF
  153.   #FOR(%PrimaryConditionalIcons)
  154.     #INSERT(%AddBrowseIcon,%PrimaryConditionalIcon)
  155.   #ENDFOR
  156. #ENDIF
  157. #FOR(%Secondary),WHERE(%SecondaryType = 'MANY:1')
  158.   #IF(%SecondaryUpdate)
  159.     #SET(%UpdatesPresent,%True)
  160.   #ENDIF
  161.   #FIX(%TreeLevelFile,%SecondaryTo)
  162.   #SET(%TreeChildFile,%Secondary)
  163.   #SET(%TempLevel,%TreeLevel + 1)
  164.   #FIX(%File,%Secondary)
  165.   #FIX(%Relation,%SecondaryTo)
  166.   #SET(%TempParent,%Relation)
  167.   #SET(%TempParentKey,%RelationKey)
  168.   #ADD(%TreeLevelFile,%Secondary)
  169.   #SET(%TreeLevel,%TempLevel)
  170.   #SET(%TreeParentFile,%TempParent)
  171.   #SET(%TreeParentKey,%TempParentKey)
  172.   #SET(%TreeDisplay,%SecondaryDisplay)
  173.   #IF(%ControlHasIcon)
  174.     #IF(%SecondaryDefaultIcon)
  175.       #INSERT(%AddBrowseIcon,%SecondaryDefaultIcon)
  176.     #ENDIF
  177.     #FOR(%SecondaryConditionalIcons)
  178.       #INSERT(%AddBrowseIcon,%SecondaryConditionalIcon)
  179.     #ENDFOR
  180.   #ENDIF
  181. #ENDFOR
  182. #SET(%InstancePrefix,'REL' & %ActiveTemplateInstance & ':')
  183. #ENDAT
  184. #!-------------------------------------------------------------------------
  185. #AT(%DataSectionBeforeWindow)
  186. %[20]TreeQueue QUEUE,PRE()                      #<! Browsing Queue
  187.   #SET(%ValueConstruct,%InstancePrefix & ':Display')
  188. %[20]ValueConstruct STRING(200)                 #<! Queue position of scroll thumb
  189.   #FIX(%Control,%TreeControl)
  190.   #SELECT(%ControlField,1)
  191.   #IF(%ControlHasColor)
  192.     #SET(%ValueConstruct,%InstancePrefix & ':NormalFG')
  193. %[20]ValueConstruct LONG
  194.     #SET(%ValueConstruct,%InstancePrefix & ':NormalBG')
  195. %[20]ValueConstruct LONG
  196.     #SET(%ValueConstruct,%InstancePrefix & ':SelectedFG')
  197. %[20]ValueConstruct LONG
  198.     #SET(%ValueConstruct,%InstancePrefix & ':SelectedBG')
  199. %[20]ValueConstruct LONG
  200.   #ENDIF
  201.   #IF(%ControlHasIcon)
  202.     #SET(%ValueConstruct,%InstancePrefix & ':Icon')
  203. %[20]ValueConstruct SHORT
  204.   #ENDIF
  205.   #SET(%ValueConstruct,%InstancePrefix & ':Level')
  206. %[20]ValueConstruct LONG                        #<! Queue position of scroll thumb
  207.   #SET(%ValueConstruct,%InstancePrefix & ':Loaded')
  208. %[20]ValueConstruct SHORT                       #<! Queue position of scroll thumb
  209.   #SET(%ValueConstruct,%InstancePrefix & ':Position')
  210. %[20]ValueConstruct STRING(512)                 #<! Queue position of scroll thumb
  211.                 END
  212.   #SET(%ValueConstruct,%InstancePrefix & ':LoadedQueue')
  213. %[20]ValueConstruct QUEUE,PRE()                 #<! Status Queue
  214.   #SET(%ValueConstruct,%InstancePrefix & ':LoadedLevel')
  215. %[20]ValueConstruct LONG                        #<! Queue position of scroll thumb
  216.   #SET(%ValueConstruct,%InstancePrefix & ':LoadedPosition')
  217. %[20]ValueConstruct STRING(512)                 #<! Queue position of scroll thumb
  218.                END
  219.   #SET(%ValueConstruct,%InstancePrefix & ':CurrentLevel')
  220. %[20]ValueConstruct LONG                        #<! Queue position of scroll thumb
  221.   #SET(%ValueConstruct,%InstancePrefix & ':CurrentChoice')
  222. %[20]ValueConstruct LONG                        #<! Queue position of scroll thumb
  223.   #SET(%ValueConstruct,%InstancePrefix & ':NewItemLevel')
  224. %[20]ValueConstruct LONG                        #<! Queue position of scroll thumb
  225.   #SET(%ValueConstruct,%InstancePrefix & ':NewItemPosition')
  226. %[20]ValueConstruct STRING(512)                 #<! Queue position of scroll thumb
  227. #ENDAT
  228. #!-------------------------------------------------------------------------
  229. #AT(%BeforeWindowOpening)
  230. #SELECT(%TreeLevelFile,1)
  231. DO %InstancePrefix:Load:%TreeLevelFile
  232. #ENDAT
  233. #!-------------------------------------------------------------------------
  234. #AT(%AfterWindowOpening)
  235. #FIX(%Control,%TreeControl)
  236. #IF(%ControlHasIcon)
  237.   #FOR(%IconList),WHERE(%IconListType <> 'Variable')
  238.     #SET(%ValueConstruct,INSTANCE(%IconList))
  239.     #IF(%IconListType = 'Built-In')
  240. %TreeControl{Prop:IconList,%ValueConstruct} = %IconList
  241.     #ELSIF(%IconListType = 'File')
  242. %TreeControl{Prop:IconList,%ValueConstruct} = '%IconList'
  243.     #ENDIF
  244.   #ENDFOR
  245. #ENDIF
  246. %TreeControl{Prop:Selected} = 1
  247. #ENDAT
  248. #!-------------------------------------------------------------------------
  249. #AT(%PrepareAlerts)
  250. %TreeControl{Prop:Alrt,255} = CtrlRight
  251. %TreeControl{Prop:Alrt,254} = CtrlLeft
  252. #IF(%UpdatesPresent)
  253. %TreeControl{Prop:Alrt,253} = MouseLeft2
  254. #ENDIF
  255. #ENDAT
  256. #!-------------------------------------------------------------------------
  257. #AT(%ControlEventHandling,%TreeControl,'NewSelection')
  258. #IF(%UpdatesPresent)
  259. IF KEYCODE() = MouseRight
  260.   EXECUTE(POPUP('%'InsertPopupText|%'ChangePopupText|%'DeletePopupText'))
  261.     DO %InstancePrefix:AddEntry
  262.     DO %InstancePrefix:EditEntry
  263.     DO %InstancePrefix:RemoveEntry
  264.   END
  265. END
  266. #ENDIF
  267. #ENDAT
  268. #!-------------------------------------------------------------------------
  269. #AT(%WindowEventHandling,'GainFocus')
  270. %InstancePrefix:CurrentChoice = CHOICE(%TreeControl)
  271. GET(%TreeQueue,%InstancePrefix:CurrentChoice)
  272. %InstancePrefix:NewItemLevel = %InstancePrefix:Level
  273. %InstancePrefix:NewItemPosition = %InstancePrefix:Position
  274. DO %InstancePrefix:RefreshTree
  275. #ENDAT
  276. #!-------------------------------------------------------------------------
  277. #AT(%ControlEventHandling,%TreeControl,'Expanded')
  278. DO %InstancePrefix:LoadLevel
  279. #ENDAT
  280. #!-------------------------------------------------------------------------
  281. #AT(%ControlEventHandling,%TreeControl,'Contracted')
  282. DO %InstancePrefix:UnloadLevel
  283. #ENDAT
  284. #!-------------------------------------------------------------------------
  285. #AT(%ControlEventHandling,%TreeControl,'AlertKey')
  286. CASE KEYCODE()
  287. OF CtrlRight
  288.   %TreeControl{PropList:MouseDownRow} = CHOICE()
  289.   POST(Event:Expanded,%TreeControl)
  290. OF CtrlLeft
  291.   %TreeControl{PropList:MouseDownRow} = CHOICE()
  292.   POST(Event:Contracted,%TreeControl)
  293. #IF(%UpdatesPresent)
  294. OF MouseLeft2
  295.   DO %InstancePrefix:EditEntry
  296. #ENDIF
  297. END
  298. #ENDAT
  299. #!-------------------------------------------------------------------------
  300. #AT(%ControlOtherEventHandling,%TreeControl)
  301. #SET(%ValueConstruct,%True)
  302. #FOR(%ControlEvent),WHERE(%ControlEvent = 'AlertKey')
  303.   #SET(%ValueConstruct,%False)
  304. #ENDFOR
  305. #IF(%ValueConstruct)
  306. CASE EVENT()
  307. OF Event:AlertKey
  308.   CASE KEYCODE()
  309.   OF CtrlRight
  310.     %TreeControl{PropList:MouseDownRow} = CHOICE()
  311.     POST(Event:Expanded,%TreeControl)
  312.   OF CtrlLeft
  313.     %TreeControl{PropList:MouseDownRow} = CHOICE()
  314.     POST(Event:Contracted,%TreeControl)
  315.   #IF(%UpdatesPresent)
  316.   OF MouseLeft2
  317.     DO %InstancePrefix:EditEntry
  318.   #ENDIF
  319.   END
  320. END
  321. #ENDIF
  322. #ENDAT
  323. #!-------------------------------------------------------------------------
  324. #AT(%ProcedureRoutines)
  325. #FIX(%Control,%TreeControl)
  326. !---------------------------------------------------------------------------
  327. #SELECT(%TreeLevelFile,1)
  328. %InstancePrefix:Load:%TreeLevelFile ROUTINE
  329.   #IF(%TreeTitle)
  330.   %InstancePrefix:Display = '%TreeTitle'
  331.   %InstancePrefix:Loaded = 0
  332.   %InstancePrefix:Position = ''
  333.   %InstancePrefix:Level = 0
  334.     #IF(%ControlHasIcon)
  335.       #FIX(%IconList,%TreeTitleIcon)
  336.       #IF(%IconList)
  337.         #CASE(%IconListType)
  338.         #OF('Variable')
  339.   %ValueConstruct:Icon = %IconList
  340.         #ELSE
  341.           #SET(%ValueConstruct,INSTANCE(%IconList))
  342.   %InstancePrefix:Icon = %ValueConstruct
  343.         #ENDCASE
  344.       #ELSE
  345.   %InstancePrefix:Icon = 0
  346.       #ENDIF
  347.     #ENDIF
  348.     #IF(%ControlHasColor)
  349.   %InstancePrefix:NormalFG = -1
  350.   %InstancePrefix:NormalBG = -1
  351.   %InstancePrefix:SelectedFG = -1
  352.   %InstancePrefix:SelectedBG = -1
  353.     #ENDIF
  354.   ADD(%TreeQueue)
  355.   #ENDIF
  356.   #IF(%PrimaryKey)
  357.   SET(%PrimaryKey)
  358.   #ELSE
  359.   SET(%Primary)
  360.   #ENDIF
  361.   LOOP
  362.     NEXT(%TreeLevelFile)
  363.     IF ERRORCODE()
  364.       IF ERRORCODE() = BadRecErr
  365.         BREAK
  366.       ELSE
  367.         StandardWarning(Warn:RecordFetchError,'%File')
  368.         POST(Event:CloseWindow)
  369.         EXIT
  370.       END
  371.     END
  372.     %InstancePrefix:Loaded = 0
  373.   #IF(%PrimaryKey)
  374.     %InstancePrefix:Position = POSITION(%PrimaryKey)
  375.   #ELSE
  376.     %InstancePrefix:Position = POSITION(%Primary)
  377.   #ENDIF
  378.     %InstancePrefix:Level = %TreeLevel
  379.   #IF(%TreeChildFile)
  380.     %InstancePrefix:LoadedLevel = ABS(%InstancePrefix:Level)
  381.     %InstancePrefix:LoadedPosition = %InstancePrefix:Position
  382.     GET(%InstancePrefix:LoadedQueue,%InstancePrefix:LoadedLevel,%InstancePrefix:LoadedPosition)
  383.     IF ERRORCODE()
  384.     #FIX(%File,%TreeChildFile)
  385.     #FIX(%Relation,%TreeLevelFile)
  386.     #FIX(%Key,%FileKey)
  387.     #FOR(%RelationKeyField)
  388.       #IF(%RelationKeyField)
  389.       %RelationKeyFieldLink = %RelationKeyField
  390.       #ELSE
  391.         #FIX(%KeyField,%RelationKeyFieldLink)
  392.         #IF(%KeyFieldSequence = 'ASCENDING')
  393.       CLEAR(%KeyField,0)
  394.         #ELSE
  395.       CLEAR(%KeyField,1)
  396.         #ENDIF
  397.       #ENDIF
  398.     #ENDFOR
  399.       SET(%FileKey,%FileKey)
  400.       LOOP
  401.         NEXT(%File)
  402.         IF ERRORCODE()
  403.           IF ERRORCODE() = BadRecErr
  404.             BREAK
  405.           ELSE
  406.             StandardWarning(Warn:RecordFetchError,'%File')
  407.             POST(Event:CloseWindow)
  408.             EXIT
  409.           END
  410.         END
  411.     #FOR(%RelationKeyField),WHERE(%RelationKeyField)
  412.       #IF(%KeyNoCase)
  413.         IF UPPER(%RelationKeyFieldLink) <> UPPER(%RelationKeyField) THEN BREAK.
  414.       #ELSE
  415.         IF %RelationKeyFieldLink <> %RelationKeyField THEN BREAK.
  416.       #ENDIF
  417.     #ENDFOR
  418.         %InstancePrefix:Level = -%TreeLevel
  419.         BREAK
  420.       END
  421.       DO %InstancePrefix:Format:%TreeLevelFile
  422.       ADD(%TreeQueue,POINTER(%TreeQueue)+1)
  423.     ELSE
  424.       %InstancePrefix:Level = %TreeLevel
  425.       %InstancePrefix:Loaded = True
  426.       DO %InstancePrefix:Format:%TreeLevelFile
  427.       ADD(%TreeQueue,POINTER(%TreeQueue)+1)
  428.       DO %InstancePrefix:Load:%TreeChildFile
  429.     END
  430.   #ELSE
  431.     DO %InstancePrefix:Format:%TreeLevelFile
  432.     ADD(%TreeQueue,POINTER(%TreeQueue)+1)
  433.   #ENDIF
  434.   END
  435.  
  436. !---------------------------------------------------------------------------
  437. %InstancePrefix:Format:%TreeLevelFile ROUTINE
  438.   #IF(%TreeDisplay)
  439.   DisplayString = %TreeDisplay
  440.   #ELSE
  441.   CLEAR(DisplayString)
  442.   #ENDIF
  443.   #EMBED(%BeforePrimaryDisplay,'Before Setting Display on Primary File'),%ActiveTemplateInstance,MAP(%ActiveTemplateInstance,%ActiveTemplateinstanceDescription)
  444.   %InstancePrefix:Display = DisplayString
  445.   #IF(%ControlHasColor)
  446.     #IF(ITEMS(%PrimaryConditionalColors))
  447.       #FOR(%PrimaryConditionalColors)
  448.         #IF(INSTANCE(%PrimaryConditionalColors) = 1)
  449.   IF %PrimaryColorCondition
  450.         #ELSE
  451.   ELSIF %PrimaryColorCondition
  452.         #ENDIF
  453.     %InstancePrefix:NormalFG = %ConditionalPrimaryForegroundNormal
  454.     %InstancePrefix:NormalBG = %ConditionalPrimaryBackgroundNormal
  455.     %InstancePrefix:SelectedFG = %ConditionalPrimaryForegroundSelected
  456.     %InstancePrefix:SelectedBG = %ConditionalPrimaryBackgroundSelected
  457.       #ENDFOR
  458.   ELSE
  459.     %InstancePrefix:NormalFG = %DefaultPrimaryForegroundNormal
  460.     %InstancePrefix:NormalBG = %DefaultPrimaryBackgroundNormal
  461.     %InstancePrefix:SelectedFG = %DefaultPrimaryForegroundSelected
  462.     %InstancePrefix:SelectedBG = %DefaultPrimaryBackgroundSelected
  463.   END
  464.     #ELSE
  465.   %InstancePrefix:NormalFG = %DefaultPrimaryForegroundNormal
  466.   %InstancePrefix:NormalBG = %DefaultPrimaryBackgroundNormal
  467.   %InstancePrefix:SelectedFG = %DefaultPrimaryForegroundSelected
  468.   %InstancePrefix:SelectedBG = %DefaultPrimaryBackgroundSelected
  469.     #ENDIF
  470.   #ENDIF
  471.   #IF(%ControlHasIcon)
  472.     #IF(ITEMS(%PrimaryConditionalIcons))
  473.       #FOR(%PrimaryConditionalIcons)
  474.         #IF(INSTANCE(%PrimaryConditionalIcons) = 1)
  475.   IF %PrimaryIconCondition
  476.         #ELSE
  477.   ELSIF %PrimaryIconCondition
  478.         #ENDIF
  479.         #FIX(%IconList,%PrimaryConditionalIcon)
  480.         #IF(%IconList)
  481.           #CASE(%IconListType)
  482.           #OF('Variable')
  483.     %ValueConstruct:Icon = %IconList
  484.           #ELSE
  485.             #SET(%ValueConstruct,INSTANCE(%IconList))
  486.     %InstancePrefix:Icon = %ValueConstruct
  487.           #ENDCASE
  488.         #ELSE
  489.     %InstancePrefix:Icon = 0
  490.         #ENDIF
  491.       #ENDFOR
  492.   ELSE
  493.       #FIX(%IconList,%PrimaryDefaultIcon)
  494.       #IF(%IconList)
  495.         #CASE(%IconListType)
  496.         #OF('Variable')
  497.     %InstancePrefix:Icon = %IconList
  498.         #ELSE
  499.           #SET(%ValueConstruct,INSTANCE(%IconList))
  500.     %InstancePrefix:Icon = %ValueConstruct
  501.         #ENDCASE
  502.       #ELSE
  503.     %InstancePrefix:Icon = 0
  504.       #ENDIF
  505.   END
  506.     #ELSE
  507.       #FIX(%IconList,%PrimaryDefaultIcon)
  508.       #IF(%IconList)
  509.         #CASE(%IconListType)
  510.         #OF('Variable')
  511.   %InstancePrefix:Icon = %IconList
  512.         #ELSE
  513.           #SET(%ValueConstruct,INSTANCE(%IconList))
  514.   %InstancePrefix:Icon = %ValueConstruct
  515.         #ENDCASE
  516.       #ELSE
  517.   %InstancePrefix:Icon = 0
  518.       #ENDIF
  519.     #ENDIF
  520.   #ENDIF
  521.  
  522. !---------------------------------------------------------------------------
  523. %InstancePrefix:LoadLevel ROUTINE
  524.   %InstancePrefix:CurrentChoice = %TreeControl{PropList:MouseDownRow}
  525.   GET(%TreeQueue,%InstancePrefix:CurrentChoice)
  526.   IF NOT %InstancePrefix:Loaded
  527.     %InstancePrefix:Level = ABS(%InstancePrefix:Level)
  528.     PUT(%TreeQueue)
  529.     %InstancePrefix:Loaded = True
  530.     %InstancePrefix:LoadedLevel = ABS(%InstancePrefix:Level)
  531.     %InstancePrefix:LoadedPosition = %InstancePrefix:Position
  532.     ADD(%InstancePrefix:LoadedQueue,%InstancePrefix:LoadedLevel,%InstancePrefix:LoadedPosition)
  533.     EXECUTE(ABS(%InstancePrefix:Level))
  534.   #FOR(%TreeLevelFile)
  535.       BEGIN
  536.         REGET(%TreeLevelFile,%InstancePrefix:Position)
  537.         DO %InstancePrefix:Format:%TreeLevelFile
  538.       END
  539.   #ENDFOR
  540.     END
  541.     PUT(%TreeQueue)
  542.     EXECUTE(ABS(%InstancePrefix:Level))
  543.   #FOR(%TreeLevelFile),WHERE(INSTANCE(%TreeLevelFile) > 1)
  544.       DO %InstancePrefix:Load:%TreeLevelFile
  545.   #ENDFOR
  546.     END
  547.   END
  548. !---------------------------------------------------------------------------
  549. %InstancePrefix:UnloadLevel ROUTINE
  550.   %InstancePrefix:CurrentChoice = %TreeControl{PropList:MouseDownRow}
  551.   GET(%TreeQueue,%InstancePrefix:CurrentChoice)
  552.   IF %InstancePrefix:Loaded
  553.     %InstancePrefix:Level = -ABS(%InstancePrefix:Level)
  554.     PUT(%TreeQueue)
  555.     %InstancePrefix:Loaded = False
  556.     %InstancePrefix:LoadedLevel = ABS(%InstancePrefix:Level)
  557.     %InstancePrefix:LoadedPosition = %InstancePrefix:Position
  558.     GET(%InstancePrefix:LoadedQueue,%InstancePrefix:LoadedLevel,%InstancePrefix:LoadedPosition)
  559.     IF NOT ERRORCODE()
  560.       DELETE(%InstancePrefix:LoadedQueue)
  561.     END
  562.     EXECUTE(ABS(%InstancePrefix:Level))
  563.   #FOR(%TreeLevelFile)
  564.       BEGIN
  565.         REGET(%TreeLevelFile,%InstancePrefix:Position)
  566.         DO %InstancePrefix:Format:%TreeLevelFile
  567.       END
  568.   #ENDFOR
  569.     END
  570.     PUT(%TreeQueue)
  571.     %InstancePrefix:CurrentLevel = ABS(%InstancePrefix:Level)
  572.     %InstancePrefix:CurrentChoice += 1
  573.     LOOP
  574.       GET(%TreeQueue,%InstancePrefix:CurrentChoice)
  575.       IF ERRORCODE() THEN BREAK.
  576.       IF ABS(%InstancePrefix:Level) <= %InstancePrefix:CurrentLevel THEN BREAK.
  577.       DELETE(%TreeQueue)
  578.     END
  579.   END
  580. #FOR(%TreeLevelFile),WHERE(INSTANCE(%TreeLevelFile) > 1)
  581. !---------------------------------------------------------------------------
  582. %InstancePrefix:Load:%TreeLevelFile ROUTINE
  583.   #FIX(%File,%TreeLevelFile)
  584.   #FIX(%Relation,%TreeParentFile)
  585.   #FIX(%Key,%FileKey)
  586.   #FOR(%RelationKeyField)
  587.     #IF(%RelationKeyField)
  588.   %RelationKeyFieldLink = %RelationKeyField
  589.     #ELSE
  590.       #FIX(%KeyField,%RelationKeyFieldLink)
  591.       #IF(%KeyFieldSequence = 'ASCENDING')
  592.   CLEAR(%RelationKeyFieldLink)
  593.       #ELSE
  594.   CLEAR(%RelationKeyFieldLink,1)
  595.       #ENDIF
  596.     #ENDIF
  597.   #ENDFOR
  598.   SET(%FileKey,%FileKey)
  599.   LOOP
  600.     NEXT(%File)
  601.     IF ERRORCODE()
  602.       IF ERRORCODE() = BadRecErr
  603.         BREAK
  604.       ELSE
  605.         StandardWarning(Warn:RecordFetchError,'%File')
  606.         POST(Event:CloseWindow)
  607.         EXIT
  608.       END
  609.     END
  610.   #FOR(%RelationKeyField),WHERE(%RelationKeyField)
  611.     IF %RelationKeyFieldLink <> %RelationKeyField THEN BREAK.
  612.   #ENDFOR
  613.     %InstancePrefix:Loaded = 0
  614.     %InstancePrefix:Position = POSITION(%TreeLevelFile)
  615.     %InstancePrefix:Level = %TreeLevel
  616.   #IF(%TreeChildFile)
  617.     %InstancePrefix:LoadedLevel = ABS(%InstancePrefix:Level)
  618.     %InstancePrefix:LoadedPosition = %InstancePrefix:Position
  619.     GET(%InstancePrefix:LoadedQueue,%InstancePrefix:LoadedLevel,%InstancePrefix:LoadedPosition)
  620.     IF ERRORCODE()
  621.     #FIX(%File,%TreeChildFile)
  622.     #FIX(%Relation,%TreeLevelFile)
  623.     #FIX(%Key,%FileKey)
  624.     #FOR(%RelationKeyField)
  625.       #IF(%RelationKeyField)
  626.       %RelationKeyFieldLink = %RelationKeyField
  627.       #ELSE
  628.         #FIX(%KeyField,%RelationKeyFieldLink)
  629.         #IF(%KeyFieldSequence = 'ASCENDING')
  630.       CLEAR(%KeyField,0)
  631.         #ELSE
  632.       CLEAR(%KeyField,1)
  633.         #ENDIF
  634.       #ENDIF
  635.     #ENDFOR
  636.       SET(%FileKey,%FileKey)
  637.       LOOP
  638.         NEXT(%File)
  639.         IF ERRORCODE()
  640.           IF ERRORCODE() = BadRecErr
  641.             BREAK
  642.           ELSE
  643.             StandardWarning(Warn:RecordFetchError,'%File')
  644.             POST(Event:CloseWindow)
  645.             EXIT
  646.           END
  647.         END
  648.     #FOR(%RelationKeyField),WHERE(%RelationKeyField)
  649.       #IF(%KeyNoCase)
  650.         IF UPPER(%RelationKeyFieldLink) <> UPPER(%RelationKeyField) THEN BREAK.
  651.       #ELSE
  652.         IF %RelationKeyFieldLink <> %RelationKeyField THEN BREAK.
  653.       #ENDIF
  654.     #ENDFOR
  655.         %InstancePrefix:Level = -%TreeLevel
  656.         BREAK
  657.       END
  658.       DO %InstancePrefix:Format:%TreeLevelFile
  659.       ADD(%TreeQueue,POINTER(%TreeQueue)+1)
  660.     ELSE
  661.       %InstancePrefix:Level = %TreeLevel
  662.       %InstancePrefix:Loaded = True
  663.       DO %InstancePrefix:Format:%TreeLevelFile
  664.       ADD(%TreeQueue,POINTER(%TreeQueue)+1)
  665.       DO %InstancePrefix:Load:%TreeChildFile
  666.     END
  667.   #ELSE
  668.     DO %InstancePrefix:Format:%TreeLevelFile
  669.     ADD(%TreeQueue,POINTER(%TreeQueue)+1)
  670.   #ENDIF
  671.   END
  672.  
  673. !-------------------------------------------------------
  674. %InstancePrefix:Format:%TreeLevelFile ROUTINE
  675.   #FIX(%File,%Primary)
  676.   #FIX(%Secondary,%TreeLevelFile)
  677.   #IF(%TreeDisplay)
  678.   DisplayString = %TreeDisplay
  679.   #ELSE
  680.   CLEAR(DisplayString)
  681.   #ENDIF
  682.   #EMBED(%BeforeSecondaryDisplay,'Before Setting Display on Secondary File'),%ActiveTemplateInstance,%Secondary,MAP(%ActiveTemplateInstance,%ActiveTemplateinstanceDescription),MAP(%Secondary,' on ' & %Secondary)
  683.   #FIX(%File,%TreeLevelFile)
  684.   #FIX(%Relation,%TreeParentFile)
  685.   %InstancePrefix:Display = DisplayString
  686.   #IF(%ControlHasColor)
  687.     #IF(ITEMS(%SecondaryConditionalColors))
  688.       #FOR(%SecondaryConditionalColors)
  689.         #IF(INSTANCE(%SecondaryConditionalColors) = 1)
  690.   IF %SecondaryColorCondition
  691.         #ELSE
  692.   ELSIF %SecondaryColorCondition
  693.         #ENDIF
  694.     %InstancePrefix:NormalFG = %ConditionalSecondaryForegroundNormal
  695.     %InstancePrefix:NormalBG = %ConditionalSecondaryBackgroundNormal
  696.     %InstancePrefix:SelectedFG = %ConditionalSecondaryForegroundSelected
  697.     %InstancePrefix:SelectedBG = %ConditionalSecondaryBackgroundSelected
  698.       #ENDFOR
  699.   ELSE
  700.     %InstancePrefix:NormalFG = %DefaultSecondaryForegroundNormal
  701.     %InstancePrefix:NormalBG = %DefaultSecondaryBackgroundNormal
  702.     %InstancePrefix:SelectedFG = %DefaultSecondaryForegroundSelected
  703.     %InstancePrefix:SelectedBG = %DefaultSecondaryBackgroundSelected
  704.   END
  705.     #ELSE
  706.   %InstancePrefix:NormalFG = %DefaultSecondaryForegroundNormal
  707.   %InstancePrefix:NormalBG = %DefaultSecondaryBackgroundNormal
  708.   %InstancePrefix:SelectedFG = %DefaultSecondaryForegroundSelected
  709.   %InstancePrefix:SelectedBG = %DefaultSecondaryBackgroundSelected
  710.     #ENDIF
  711.   #ENDIF
  712.   #IF(%ControlHasIcon)
  713.     #IF(ITEMS(%SecondaryConditionalIcons))
  714.       #FOR(%SecondaryConditionalIcons)
  715.         #IF(INSTANCE(%SecondaryConditionalIcons) = 1)
  716.   IF %SecondaryIconCondition
  717.         #ELSE
  718.   ELSIF %SecondaryIconCondition
  719.         #ENDIF
  720.         #FIX(%IconList,%SecondaryConditionalIcon)
  721.         #IF(%IconList)
  722.           #CASE(%IconListType)
  723.           #OF('Variable')
  724.     %InstancePrefix:Icon = %IconList
  725.           #ELSE
  726.             #SET(%ValueConstruct,INSTANCE(%IconList))
  727.     %InstancePrefix:Icon = %ValueConstruct
  728.           #ENDCASE
  729.         #ELSE
  730.     %InstancePrefix:Icon = 0
  731.         #ENDIF
  732.       #ENDFOR
  733.   ELSE
  734.       #FIX(%IconList,%SecondaryDefaultIcon)
  735.       #IF(%IconList)
  736.         #CASE(%IconListType)
  737.         #OF('Variable')
  738.     %InstancePrefix:Icon = %IconList
  739.         #ELSE
  740.           #SET(%ValueConstruct,INSTANCE(%IconList))
  741.     %InstancePrefix:Icon = %ValueConstruct
  742.         #ENDCASE
  743.       #ELSE
  744.     %InstancePrefix:Icon = 0
  745.       #ENDIF
  746.   END
  747.     #ELSE
  748.       #FIX(%IconList,%SecondaryDefaultIcon)
  749.       #IF(%IconList)
  750.         #CASE(%IconListType)
  751.         #OF('Variable')
  752.   %InstancePrefix:Icon = %IconList
  753.         #ELSE
  754.           #SET(%ValueConstruct,INSTANCE(%IconList))
  755.   %InstancePrefix:Icon = %ValueConstruct
  756.         #ENDCASE
  757.       #ELSE
  758.   %InstancePrefix:Icon = 0
  759.       #ENDIF
  760.     #ENDIF
  761.   #ENDIF
  762. #ENDFOR
  763.   #EMBED(%BeforeAddingSecondaryToQueue,'Before Adding Secondary Record to Queue'),%ActiveTemplateInstance,%Secondary,MAP(%ActiveTemplateInstance,%ActiveTemplateinstanceDescription),MAP(%Secondary,' on ' & %Secondary)
  764.  
  765. #IF(%UpdatesPresent)
  766. !---------------------------------------------------------------------------
  767. %InstancePrefix:AddEntry ROUTINE
  768.   #EMBED(%BeginAddEntryRoutine,'Beginning of Add Record Routine'),%ActiveTemplateInstance,MAP(%ActiveTemplateInstance,%ActiveTemplateinstanceDescription)
  769.   %InstancePrefix:CurrentChoice = %TreeControl{PropList:MouseDownRow}
  770.   GET(%TreeQueue,%InstancePrefix:CurrentChoice)
  771.   CASE ABS(%InstancePrefix:Level)
  772.   #IF(%PrimaryUpdate)
  773.   OF 0
  774.     #EMBED(%BeforePreparingRecordOnAdd,'Before Preparing Record for Add'),%ActiveTemplateInstance,%Primary,MAP(%ActiveTemplateInstance,%ActiveTemplateinstanceDescription)
  775.     #FIX(%File,%Primary)
  776.     GET(%File,0)
  777.     #FOR(%Field),WHERE(%FieldType = 'MEMO')
  778.     CLEAR(%Field)
  779.     #ENDFOR
  780.     CLEAR(%FilePrefix:Record)
  781.     GlobalRequest = InsertRecord
  782.     #EMBED(%BeforeCallingUpdateOnAdd,'Before Update Procedure on Add'),%ActiveTemplateInstance,%Primary,MAP(%ActiveTemplateInstance,%ActiveTemplateinstanceDescription)
  783.     %PrimaryUpdate
  784.     IF GlobalResponse = RequestCompleted
  785.       %InstancePrefix:NewItemLevel = 1
  786.       %InstancePrefix:NewItemPosition = POSITION(%File)
  787.       DO %InstancePrefix:RefreshTree
  788.     END
  789.     #EMBED(%AfterCallingUpdateOnAdd,'After Update Procedure on Add'),%ActiveTemplateInstance,%Primary,MAP(%ActiveTemplateInstance,%ActiveTemplateinstanceDescription)
  790.   #ENDIF
  791.   #FOR(%TreeLevelFile),WHERE(INSTANCE(%TreeLevelFile) > 1)
  792.     #SUSPEND
  793.       #SET(%ValueConstruct,INSTANCE(%TreeLevelFile)-1)
  794.   #?OF %ValueConstruct
  795.       #IF(INSTANCE(%TreeLevelFile) = ITEMS(%TreeLevelFile))
  796.         #SET(%ValueConstruct,%ValueConstruct + 1)
  797.   #?OROF %ValueConstruct
  798.     #?IF ABS(%InstancePrefix:Level) = 3
  799.       #?LOOP
  800.         #?%InstancePrefix:CurrentChoice -= 1
  801.         #?GET(%TreeQueue,%InstancePrefix:CurrentChoice)
  802.         #?IF ERRORCODE() THEN BREAK.
  803.         #?IF ABS(%InstancePrefix:Level) = %ValueConstruct THEN CYCLE.
  804.         #?BREAK
  805.       #?END
  806.     #?END
  807.       #ENDIF
  808.     #?REGET(%TreeParentFile,%InstancePrefix:Position)
  809.     #EMBED(%BeforePreparingRecordOnAdd,'Before Preparing Record for Add'),%ActiveTemplateInstance,%Primary,MAP(%ActiveTemplateInstance,%ActiveTemplateinstanceDescription)
  810.     #?GET(%TreeLevelFile,0)
  811.       #FIX(%File,%TreeLevelFile)
  812.     #?CLEAR(%FilePrefix:Record)
  813.       #FOR(%Field),WHERE(%FieldType = 'MEMO')
  814.     #?CLEAR(%Field)
  815.       #ENDFOR
  816.       #FIX(%Relation,%TreeParentFile)
  817.       #FOR(%FileKeyField),WHERE(%FileKeyField AND %FileKeyFieldLink)
  818.     #?%FileKeyField = %FileKeyFieldLink
  819.       #ENDFOR
  820.     #?GlobalRequest = InsertRecord
  821.       #FIX(%File,%Primary)
  822.       #FIX(%Secondary,%TreeLevelFile)
  823.     #EMBED(%BeforeCallingUpdateOnAdd,'Before Update Procedure on Add'),%ActiveTemplateInstance,%Secondary,MAP(%ActiveTemplateInstance,%ActiveTemplateinstanceDescription)
  824.     %SecondaryUpdate
  825.     #?IF GlobalResponse = RequestCompleted
  826.       #?%InstancePrefix:NewItemLevel = 1
  827.       #?%InstancePrefix:NewItemPosition = POSITION(%Secondary)
  828.       #?DO %InstancePrefix:RefreshTree
  829.     #?END
  830.     #EMBED(%AfterCallingUpdateOnAdd,'After Update Procedure on Add'),%ActiveTemplateInstance,%Secondary,MAP(%ActiveTemplateInstance,%ActiveTemplateinstanceDescription)
  831.     #RESUME
  832.   #ENDFOR
  833.   END
  834. !---------------------------------------------------------------------------
  835. %InstancePrefix:EditEntry ROUTINE
  836.   #EMBED(%BeginEditEntryRoutine,'Beginning of Edit Record Routine'),%ActiveTemplateInstance,HIDE
  837.   %InstancePrefix:CurrentChoice = %TreeControl{PropList:MouseDownRow}
  838.   GET(%TreeQueue,%InstancePrefix:CurrentChoice)
  839.   CASE ABS(%InstancePrefix:Level)
  840.   #FIX(%File,%Primary)
  841.   #FOR(%TreeLevelFile)
  842.     #SUSPEND
  843.       #SET(%ValueConstruct,INSTANCE(%TreeLevelFile))
  844.   #?OF %ValueConstruct
  845.     #?REGET(%TreeLevelFile,%InstancePrefix:Position)
  846.     #?GlobalRequest = ChangeRecord
  847.       #IF(%ValueConstruct = 1)
  848.     #EMBED(%BeforeCallingUpdateOnEdit,'Before Update Procedure on Edit'),%ActiveTemplateInstance,%Primary,MAP(%ActiveTemplateInstance,%ActiveTemplateinstanceDescription)
  849.     %PrimaryUpdate
  850.       #ELSE
  851.         #FIX(%Secondary,%TreeLevelFile)
  852.     #EMBED(%BeforeCallingUpdateOnEdit,'Before Update Procedure on Edit'),%ActiveTemplateInstance,%Secondary,MAP(%ActiveTemplateInstance,%ActiveTemplateinstanceDescription)
  853.     %SecondaryUpdate
  854.       #ENDIF
  855.     #?IF GlobalResponse = RequestCompleted
  856.       #?%InstancePrefix:NewItemLevel = 1
  857.       #?%InstancePrefix:NewItemPosition = POSITION(%TreeLevelFile)
  858.       #?DO %InstancePrefix:RefreshTree
  859.     #?END
  860.       #IF(%ValueConstruct = 1)
  861.     #EMBED(%AfterCallingUpdateOnEdit,'After Update Procedure on Edit'),%ActiveTemplateInstance,%Primary,MAP(%ActiveTemplateInstance,%ActiveTemplateinstanceDescription)
  862.       #ELSE
  863.     #EMBED(%AfterCallingUpdateOnEdit,'After Update Procedure on Edit'),%ActiveTemplateInstance,%Secondary,MAP(%ActiveTemplateInstance,%ActiveTemplateinstanceDescription)
  864.       #ENDIF
  865.     #RESUME
  866.   #ENDFOR
  867.   END
  868. !---------------------------------------------------------------------------
  869. %InstancePrefix:RemoveEntry ROUTINE
  870.   #EMBED(%BeginRemoveEntryRoutine,'Beginning of Remove Record Routine'),%ActiveTemplateInstance,HIDE
  871.   %InstancePrefix:CurrentChoice = %TreeControl{PropList:MouseDownRow}
  872.   GET(%TreeQueue,%InstancePrefix:CurrentChoice)
  873.   CASE ABS(%InstancePrefix:Level)
  874.   #FIX(%File,%Primary)
  875.   #FOR(%TreeLevelFile)
  876.     #SUSPEND
  877.       #SET(%ValueConstruct,INSTANCE(%TreeLevelFile))
  878.   #?OF %ValueConstruct
  879.     #?REGET(%TreeLevelFile,%InstancePrefix:Position)
  880.     #?GlobalRequest = DeleteRecord
  881.       #IF(%ValueConstruct = 1)
  882.     #EMBED(%BeforeCallingUpdateOnRemove,'Before Update Procedure on Remove'),%ActiveTemplateInstance,%Primary,MAP(%ActiveTemplateInstance,%ActiveTemplateinstanceDescription)
  883.     %PrimaryUpdate
  884.       #ELSE
  885.         #FIX(%Secondary,%TreeLevelFile)
  886.     #EMBED(%BeforeCallingUpdateOnRemove,'Before Update Procedure on Remove'),%ActiveTemplateInstance,%Secondary,MAP(%ActiveTemplateInstance,%ActiveTemplateinstanceDescription)
  887.     %SecondaryUpdate
  888.       #ENDIF
  889.     #?IF GlobalResponse = RequestCompleted
  890.       #?DO %InstancePrefix:RefreshTree
  891.     #?END
  892.       #IF(%ValueConstruct = 1)
  893.     #EMBED(%AfterCallingUpdateOnRemove,'After Update Procedure on Remove'),%ActiveTemplateInstance,%Primary,MAP(%ActiveTemplateInstance,%ActiveTemplateinstanceDescription)
  894.       #ELSE
  895.     #EMBED(%AfterCallingUpdateOnRemove,'After Update Procedure on Remove'),%ActiveTemplateInstance,%Secondary,MAP(%ActiveTemplateInstance,%ActiveTemplateinstanceDescription)
  896.       #ENDIF
  897.     #RESUME
  898.   #ENDFOR
  899.   END
  900. #ENDIF
  901. !---------------------------------------------------------------------------
  902. %InstancePrefix:RefreshTree ROUTINE
  903.   FREE(%TreeQueue)
  904.   DO %InstancePrefix:Load:%Primary
  905.   IF %InstancePrefix:NewItemLevel
  906.     %InstancePrefix:CurrentChoice = 0
  907.     LOOP
  908.       %InstancePrefix:CurrentChoice += 1
  909.       GET(%TreeQueue,%InstancePrefix:CurrentChoice)
  910.       IF ERRORCODE() THEN BREAK.
  911.       IF ABS(%InstancePrefix:Level) <> ABS(%InstancePrefix:NewItemLevel) THEN CYCLE.
  912.       IF %InstancePrefix:Position <> %InstancePrefix:NewItemPosition THEN CYCLE.
  913.       SELECT(%TreeControl,%InstancePrefix:CurrentChoice)
  914.       BREAK
  915.     END
  916.   END
  917. #ENDAT
  918. #!---------------------------------------------------------------------------
  919. #CONTROL(RelTreeUpdateButtons,'Update buttons for a Relation Tree'),DESCRIPTION('Update buttons for a Relation Tree for ' & %Primary),REQ(RelationTree),HLP('~TPLControlBrowseUpdateButtons')
  920.   CONTROLS
  921.        BUTTON('&Insert'),AT(,,45,14),USE(?Insert)
  922.        BUTTON('&Change'),AT(50,0,45,14),USE(?Change)
  923.        BUTTON('&Delete'),AT(50,0,45,14),USE(?Delete)
  924.   END
  925. #ATSTART
  926.   #DECLARE(%AddControl)
  927.   #DECLARE(%EditControl)
  928.   #DECLARE(%RemoveControl)
  929.   #FOR(%Control),WHERE(%ControlInstance = %ActiveTemplateInstance)
  930.     #CASE(%ControlOriginal)
  931.     #OF('?Insert')
  932.     #OROF('?Add')
  933.       #SET(%AddControl,%Control)
  934.       #SET(%ValueConstruct,EXTRACT(%ControlStatement,'BUTTON',1))
  935.       #SET(%InsertPopupText,SUB(%ValueConstruct,2,LEN(%ValueConstruct)-2))
  936.     #OF('?Change')
  937.     #OROF('?Edit')
  938.       #SET(%EditControl,%Control)
  939.       #SET(%ValueConstruct,EXTRACT(%ControlStatement,'BUTTON',1))
  940.       #SET(%ChangePopupText,SUB(%ValueConstruct,2,LEN(%ValueConstruct)-2))
  941.     #OF('?Delete')
  942.     #OROF('?Remove')
  943.       #SET(%RemoveControl,%Control)
  944.       #SET(%ValueConstruct,EXTRACT(%ControlStatement,'BUTTON',1))
  945.       #SET(%DeletePopupText,SUB(%ValueConstruct,2,LEN(%ValueConstruct)-2))
  946.     #ENDCASE
  947.   #ENDFOR
  948. #ENDAT
  949. #AT(%ControlEventHandling,%AddControl,'Accepted')
  950. DO %InstancePrefix:AddEntry
  951. #ENDAT
  952. #AT(%ControlEventHandling,%RemoveControl,'Accepted')
  953. DO %InstancePrefix:RemoveEntry
  954. #ENDAT
  955. #AT(%ControlEventHandling,%EditControl,'Accepted')
  956. DO %InstancePrefix:EditEntry
  957. #ENDAT
  958. #AT(%BeginAddEntryRoutine)
  959.   #IF(%Control=%TreeControl)
  960.     #IF(%AddControl)
  961. IF %AddControl{Prop:Visible} = False
  962.   EXIT
  963. ELSIF %AddControl{Prop:Disable}
  964.   EXIT
  965. END
  966.     #ENDIF
  967.   #ENDIF
  968. #ENDAT
  969. #AT(%BeginRemoveEntryRoutine)
  970.   #IF(%Control=%TreeControl)
  971.     #IF(%RemoveControl)
  972. IF %RemoveControl{Prop:Visible} = False
  973.   EXIT
  974. ELSIF %RemoveControl{Prop:Disable}
  975.   EXIT
  976. END
  977.     #ENDIF
  978.   #ENDIF
  979. #ENDAT
  980. #AT(%BeginRemoveEntryRoutine)
  981.   #IF(%Control=%TreeControl)
  982.     #IF(%RemoveControl)
  983. IF %EditControl{Prop:Visible} = False
  984.   EXIT
  985. ELSIF %EditControl{Prop:Disable}
  986.   EXIT
  987. END
  988.     #ENDIF
  989.   #ENDIF
  990. #ENDAT
  991.  
  992.